import React, { Component } from 'react'
import './List.css'

export default class List extends Component {
  render() {
    const { list,isFirst,isLoading,err } = this.props
    return (
      <div className="row">
        { isFirst?  <h2>欢迎使用，输入关键字，随后点击搜索</h2> :
          isLoading?  <h2>Loading...</h2> :
          err?  <h2 style={{color:'#da0119'}}>{err}</h2> :
          list.length===0?  <h2 style={{color:'#27779d'}}>空空如也</h2> :
          list.map(i=>{
            const { id,html_url,avatar_url,login } = i
            return (
              <div className="card" key={id}>
                <a href={html_url} target='_blank' rel='noreferrer'>
                  <img src={avatar_url} style={{width:'100px'}} alt ='avatar'/>
                </a>
                <p className="card-text">{login}</p>
              </div>
            )
          })
        }
      </div>
    )
  }
}
